-- skill_upgrade
-- create by zhuangsl
-- 附加属性：施法升级装备

return {
    apply = function(prop, baseValue)
        -- 数量
        return prop[3];
    end,

    -- 施法触发
    trigger = function(who, prop, skillId)
        -- 不是指定的技能
        if skillId ~= prop[4] then
            return;
        end

        -- 累积次数
        DungeonServiceM.addDungeonAttrib("phalanx", 1);

        -- 如果次数不够
        if DungeonServiceM.queryDungeonAttrib("phalanx") < prop[3] then
            return;
        end

        -- 扣除次数
        DungeonServiceM.costDungeonAttrib({["phalanx"] = prop[3], });

        -- 转换装备
        local arr = string.explode(prop[2], "~");
        EquipM.transformEquipment(tonumber(arr[1]), tonumber(arr[2]));

        -- 装备升级的事件
        EventMgr.fire(event.UPGRADE_EQUIP, {["classId"] = tonumber(arr[1]), });

        return true;
    end,

    desc = function(prop)
        local row = PropM.getRow(prop[1]);
        local desc = row.desc;
        local count = DungeonServiceM.queryDungeonAttrib("phalanx");
        local skillName = SkillM.query(prop[4], "name");

        desc = string.gsub(desc, "{0}", tonumber(count));
        desc = string.gsub(desc, "{1}", prop[3]);
        desc = string.gsub(desc, "{2}", skillName);

        return desc;
    end,

    record = function(target, prop, path)
        return false;
    end
};
